package com.itheima.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.controller.dto.SetMealDto;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description 套餐控制层
 * @Author makun
 * @Date 2023/9/14 15:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/setMeal")
public class SetMealController {
    @Autowired
    private SetMealService setMealService;

    /**
     * 新增一个套餐
     * @param setMealDto
     * @return
     */
    @PostMapping
    public Result saveSetMeal(SetMealDto setMealDto) {
        return setMealService.saveOne(setMealDto) ? Result.buildSuccess() : Result.buildFail();
    }

    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    @GetMapping
    public Result getSetMeal(QueryPageBean queryPageBean) {
        return Result.buildSuccess(setMealService.findPage(queryPageBean));
    }
}
